<!DOCTYPE html>
<html>

    <head>
        <meta charset="utf-8" />
        <title>文章管理</title>
        <link rel="stylesheet" href="__PUBLIC__/Leader/css/bootstrap.css">
        <link rel="stylesheet" type="text/css" href="__PUBLIC__/Leader/css/index.css" />
        <style type="text/css">
            .order-list a {
                position: relative;
            }
            .order-list span {
                float: right;
                margin-right: 20px;
            }
            .pagination ul {
                display: inline-block;
                margin-left: 0;
                margin-bottom: 0;
                -webkit-border-radius: 3px;
                -moz-border-radius: 3px;
                border-radius: 3px;
                -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
                -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
                box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
            }
            .pagination ul > li {
                display: inline;
            }
            .pagination ul > li > a, .pagination ul > li > span {
                float: left;
                padding: 0 14px;
                line-height: 38px;
                text-decoration: none;
                background-color: #ffffff;
                border: 1px solid #dddddd;
                border-left-width: 0;
            }
        </style>
    </head>
    <body>
        <include file="Index/head"/>
        <div class="wrapper main-wrapper wrapper-content ">
            <div class="page-menubar">
                <!--<div class="menu-header">文章分类管理</div>-->
                <ul class="order-list">
                    <li>
                        <a href="{:U('Article/lst')}"><img src="__PUBLIC__/images/ic-9.png" alt="" class="com-icon">文章列表</a>
                    </li>
                    <li class="active">
                        <a href="{:U('Article/type')}"><img src="__PUBLIC__/images/ic-10.png" alt="" class="com-icon">文章分类</a>
                    </li>
                    <!-- <li>
                        <a href="{:U('Line/lineadmin2')}">小件代运线路管理</a>
                    </li>
                    <li>
                        <a href="{:U('Line/addline2')}">添加代运线路</a>
                    </li> -->
                </ul>
            </div>
            <!--主要内容-->
            <div class="page-content" style="display: block;">
                <!--内容标题-->
                <div class="page-heading" style="position:relative;">
                    <h2>文章分类管理</h2>
                </div>
                <div class="panel panel-default" style="margin-top: 20px;">
                    <div class="panel-body">
                        <div id="myTabContent" class="tab-content">
                            <div class="tab-pane active in" id="home">

                                <form role="form" id="tab">

                                   <input type="hidden" name="id" value="{$id}">

                                    <div class="form-group">
                                      <label for="name">标题：</label>
                                      <input type="text" class="form-control" name="title" value="{$info['title']}" style="width:40%;">
                                    </div>
                                    <!-- <div class="form-group">
                                      <label for="name">上传图片：</label>
                                      <input type="text" class="form-control" name="ico" value="{$info['ico']}" style="width:40%;">
                                    </div> -->

                                    <div data-role="fieldcontain" class="form-group">
                                        <label for="id_photos">
                                        分类图片：
                                        </label>
                                            <input type="file" id="id_photos" name="id_photos" value="上传" style="filter:alpha(opacity=10);-moz-opacity:10;opacity:10;" />  <input type="hidden" id="ico" name="ico" value="">            
                                       
                                    </div>

                                <div class="id_photos" >
                                    
                                </div>  


                                   <!--   <div class="form-group">
                                        <label for="name">排序：</label>
                                        <input type="text" class="form-control" name="level" value="{$info['level']}" style="width:40%;">
                                    </div>
                                     -->
                                    
                                   
                                    
                                    <div class="form-group">
                                      <button  type="button" class="btn btn-primary" onclick="tj()">添加</button>
                                    </div>
                                </form>

                            </div>

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </body>
    <script src="__PUBLIC__/js/jquey.js" type="text/javascript" charset="utf-8"></script>
    <script src="__PUBLIC__/Leader/js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="__PUBLIC__/ajaxFileUpload/ajaxfileupload.js?1"></script>
   

    <script type="text/javascript">
    //照片异步上传
    $('#id_photos').change(function(){  //此处用了change事件，当选择好图片打开，关闭窗口时触发此事件
        $.ajaxFileUpload({
        url:"{:U('uploader/index')}",   //处理图片的脚本路径
        type: 'post',       //提交的方式
        secureuri :false,   //是否启用安全提交
        fileElementId :'id_photos',     //file控件ID
        dataType : 'json',  //服务器返回的数据类型      
        success : function (data, status){  //提交成功后自动执行的处理函数
            if(1 != data.total) return;　　 //因为此处指允许上传单张图片，所以数量如果不是1，那就是有错误了
            var url = data.files[0].path;　
            console.log(data.files[0]);return false;
            $('.id_photos').empty();
            //此处效果是：当成功上传后会返回一个json数据，里面有url，取出url赋给img标签，然后追加到.id_photos类里显示出图片
            $("#ico").val(url);
            $('.id_photos').append('<img src="http://xiaoyi.weixin88888888.com'+url+'" value="'+url+'" style="width:80%" >');
            //$('.upload-box').remove();
        },
        
        });
    });

    function tj() {
        $.ajax({
            type: "POST",
            url: "__CONTROLLER__/add_type",
            cache: false,
            data: $('#tab').serialize(),
            success: function (data) {
                data = $.trim(data);
                switch (data) {
                    case '0':
                        alert('添加成功');
                        window.location.replace("__CONTROLLER__/type")
                        break;
                    case '1':
                        alert('添加失败');

                        break;
                    default:
                        alert(data);
                }
            }
        })
    }
</script>
<script type="text/javascript">
    $("[rel=tooltip]").tooltip();
    $(function () {
        $('.demo-cancel-click').click(function () {
            return false;
        });
    });
</script>
</html>